package com.lazycat.backend.controller.chat;

import com.lazycat.backend.service.chat.AddGroupMessageService;
import com.lazycat.backend.service.chat.AddPersonalMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;

@RestController
public class AddGroupMessageController {
    @Autowired
    private AddGroupMessageService addGroupMessageService;

    @PostMapping("chat/addGroupMessage/")
    public HashMap<String, Object> add(@RequestBody Map<String, String> map) {
        Integer group_id = Integer.parseInt(map.get("group_id"));
        Integer sender_id = Integer.parseInt(map.get("sender_id"));
        String message = map.get("message");
        BigInteger time = new BigInteger(map.get("time"));
        return addGroupMessageService.add(group_id, sender_id, message, time);
    }
}
